package MyFile;

import java.io.File;

public class demo10 {
    public static void main(String[] args) {
        deleteFile("D:\\software\\ademo");
    }
    public static void deleteFile(String dir){
        if (dir == null){
            return;
        }
        //需要删除的文件夹
        File file = new File(dir);
        if (file.isFile() || !file.exists()){
            return;
        }
        File[] files = file.listFiles();
        if (files == null){
            return;
        }
        for (int i = 0; i < files.length; i++) {
            File tempFile = files[i];
            if (tempFile.isFile()){
                tempFile.delete();
            }else {
                deleteFile(tempFile.getAbsolutePath());
            }
        }
        file.delete();
    }
}
